package com.cdream.basic.algorithm.leetcode.dfs;

public class Question125 {
    public static void main(String[] args) {
        System.out.println(isPalindrome(" "));
    }

    public static boolean isPalindrome(String s) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if (Character.isLetterOrDigit(s.charAt(i))) {
                sb.append(s.charAt(i));
            }
        }
        s = sb.toString().toLowerCase();

        if ("".equals(s)) {
            return true;
        }
        int start = 0;
        int end = s.length() - 1;
        while (s.charAt(start) == s.charAt(end)) {
            if (end <= start) {
                return true;
            }
            end--;
            start++;
        }
        return false;
    }


}
